-- @nsURI Mapping=http://www.eclipse.org/emf/2002/Mapping -- @nsURI XSD=http://www.eclipse.org/xsd/2002/XSD -- @nsURI Ecore=http://www.eclipse.org/emf/2002/Ecore -- @nsURI ATL=http://www.eclipse.org/gmt/2005/ATL -- Header section module HOT-injection; create OUTmodel : ATL from INmodel : Mapping; -- Import section -- ******* -- HELPERS -- ******* -- ************* -- MATCHED RULES -- ************* --- ------------------------------------------------------ --- This rule takes a MappingRoot and creates --- an ATL module like this: --- --- -- @nsURI XML=http://www.eclipse.org/am3/2007/XML --- -- @nsURI MM_Name=............. --- --- -- @path XML_lib=/MAST2/Transfos/libs/XML_lib.asm --- --- -- Header section --- module MM_Name_XML_To_Ecore; --- create OUTmodel : MM_Name from INmodel : XML; --- --- -- Import section --- uses XML_lib; --- --- --- -- ***************************************** --- -- ********************** ATTRIBUTES helpers --- -- ***************************************** --- --- --- -- ***************************************** --- -- ************************* MATCHED RULES * --- -- ***************************************** --- --- --- --------------------- --- --- The main matched rule --- --- --------------------- --- rule Root_Elem { --- ... --- } --- --- -- Other matched rules --- --- ------------------------------------------------------ rule MappingRoot_to_Module { from input : Mapping!MappingRoot using { domainMM : Ecore!EPackage = input.inputs -> first(); } to output1 : ATL!Module ( -- attrs. commentsBefore <- '-- @nsURI XML=http://www.eclipse.org/am3/2007/XML', commentsBefore <- '-- @nsURI ' + domainMM.name.toUpper() + '=' + domainMM.nsURI + '\n', commentsBefore <- '-- @path XML_lib=/MAST2/Transfos/libs/XML_lib.asm' + '\n\n', commentsBefore <- '-- Header section', -- location <- , name <- domainMM.name.toUpper() + '_XML_To_Ecore', isRefining <- false, -- refs. inModels <- output2, outModels <- output3 -- libraries <- , -- elements <- {do section} ), output2 : ATL!OclModel ( -- input model -- attrs. -- location <- , name <- 'INmodel', -- refs. metamodel <- output4 -- elements <- ), output3 : ATL!OclModel ( -- output model -- attrs. -- location <- , name <- 'OUTmodel', -- refs. metamodel <- output5 -- elements <- ), output4 : ATL!OclModel ( -- source MM -- attrs. -- location <- , name <- 'XML', -- refs. -- metamodel <- Ecore, -- elements <- model <- output2 ), output5 : ATL!OclModel ( -- target MM -- attrs. -- location <- , name <- domainMM.name.toUpper(), -- refs. -- metamodel <- Ecore, -- elements <- model <- output3 ) ---- ---------------- ---- rule Root_Elem { ---- ... ---- } ---- ---------------- -- output6 : ATL!MatchedRule( -- -- attrs. ---- commentsBefore <- ---- location <- , -- name <- mainContainerCategory.id, -- isAbstract <- false, -- isNoDefault <- false, -- isRefining <- false, -- -- refs. -- module <- output1, -- inPattern <- output7, ---- variables <- -- outPattern <- output10 ---- actionBlock <- -- ), ---- --------------------------------------------- ---- from ---- input : SimpleMAST2_PRD!SimpleMAST2_Model ---- --------------------------------------------- -- output7 : ATL!InPattern( -- -- attrs. ---- location <- , -- -- refs. -- rule <- output6, -- elements <- output8 -- ), -- output8 : ATL!SimpleInPatternElement( -- input -- -- attrs. ---- location <- , -- -- refs. -- inPattern <- output7, -- varName <- 'input' ---- variableExp <- output9 ???????????????? -- ), -- output9 : ATL!OclModelElement ( -- : SimpleMAST2_PRD!SimpleMAST2_Model -- -- attrs. ---- location <- , -- name <- mainContainerCategory.id, -- -- refs. -- model <- output4, -- sourceMM -- variableDeclaration <- output8 -- ), ---- ------------------------------------ ---- to ---- output : Mast2!Mast_Model (...), ---- ------------------------------------ -- output10 : ATL!OutPattern( -- -- attrs. ---- location <- , -- -- refs. -- rule <- output6, -- elements <- output11 -- ), -- output11 : ATL!SimpleOutPatternElement( -- output -- -- attrs. ---- location <- , -- -- refs. -- outPattern <- output10, -- varName <- 'output' ---- variableExp <- output12 ???????????????? ---- bindings <- {do section} -- ), -- output12 : ATL!OclModelElement ( -- : Mast2!Mast_Model -- -- attrs. ---- location <- , -- name <- domainMMmainContainerClass.name, -- -- refs. -- model <- output5, -- targetMM -- variableDeclaration <- output11 -- ) do { for (mapping in input.nested) { thisModule.CreateMatchedRule(output1, mapping, output4, output5); } } } -- ************ -- CALLED RULES -- ************ --- --------------------------------------------------------------------------- --- This rule takes a Mapping between ComplexType <--> EClass and creates --- a matched rule like the this: --- --- rule ComplexType_Name_to_EClass_Name { --- from --- input : XML!Element (input.name = 'ComplexType_QualifiedName') --- to --- output : DomainMM!EClass_Name ( --- .... --- ) --- do { --- --- } --- } --- --------------------------------------------------------------------------- rule CreateMatchedRule(modul : ATL!Module, mapping : Mapping!Mapping, sourceMM : ATL!OclModel, targetMM : ATL!OclModel) { using { eClassName : String = mapping.inputs -> first().name; complexTypeName : String = mapping.outputs -> first().name; complexTypeQualifiedName : String = mapping.outputs -> first().qName; mappingsOnEAttrSingle : Sequence(Mapping!Mapping) = mapping.nested -> select(m | m.inputs -> first().oclIsTypeOf(Ecore!EAttribute)); -- mappingsType2 : Sequence(Mapping!MappingType2) = mapping.mappings -> select(m | m.oclIsTypeOf(Mapping!MappingType2)); -- mappingsType3 : Sequence(Mapping!MappingType3) = mapping.mappings -> select(m | m.oclIsTypeOf(Mapping!MappingType3)); -- mappingsType4 : Sequence(Mapping!MappingType4) = mapping.mappings -> select(m | m.oclIsTypeOf(Mapping!MappingType4)); -- mappingsType5 : Sequence(Mapping!MappingType5) = mapping.mappings -> select(m | m.oclIsTypeOf(Mapping!MappingType5)); } to output1 : ATL!MatchedRule ( -- attrs. -- location <- , name <- complexTypeName + '_to_' + eClassName, isAbstract <- false, isNoDefault <- false, isRefining <- false, -- refs. -- module <- inPattern <- output2, -- variables <- outPattern <- output5, actionBlock <- output8 ), -- ------------------------------------------------------------------ -- from -- input : XML!Element (input.name = 'ComplexType_QualifiedName') -- ------------------------------------------------------------------ output2 : ATL!InPattern ( -- attrs. -- location <- , -- refs. -- rule <- output1, elements <- output3, filter <- output41 ), output3 : ATL!SimpleInPatternElement ( -- input : -- attrs. -- location <- , varName <- 'input', -- refs. inPattern <- output2 ), output4 : ATL!OclModelElement ( -- : XML!Element -- attrs. -- location <- , name <- 'Element', -- refs. model <- sourceMM, variableDeclaration <- output3 ), output41 : ATL!OperatorCallExp ( -- (input.name = 'ComplexType_QualifiedName') -- attrs. -- location <- , operationName <- '=' ), output42 : ATL!NavigationOrAttributeCallExp ( -- input.name -- attrs. -- location <- , name <- 'name', -- refs source <- output43, -- input. appliedProperty <- output41 ), output43 : ATL!VariableExp ( -- input. -- attrs. -- location <- -- refs referredVariable <- output3, appliedProperty <- output42 ), output44 : ATL!StringExp ( -- 'ComplexType_QualifiedName' -- attrs. -- location <- , stringSymbol <- complexTypeQualifiedName, -- refs. parentOperation <- output41 ), -- --------------------------------------- -- to -- output : MM_Name!EClass_Name (...), -- --------------------------------------- output5 : ATL!OutPattern( -- attrs. -- location <- , -- refs. -- rule <- output1, elements <- output6 ), output6 : ATL!SimpleOutPatternElement( -- output : -- attrs. -- location <- , varName <- 'output', -- refs. outPattern <- output5 -- bindings <- {do section} ), output7 : ATL!OclModelElement ( -- : MM_Name!EClass_Name -- attrs. -- location <- , name <- eClassName, -- refs. model <- targetMM, variableDeclaration <- output6 ), output8 : ATL!ActionBlock ( -- attrs. -- refs. -- statements <- {do section} ) do { -- bindings for OutPatternElement (output6) for (mapping in mappingsOnEAttrSingle) { -- mappingt1.eAttr.upperBound = 1 -- if (mapping.eAttr.lowerBound = 1) -- required thisModule.CreateChunk1(output6, mapping.inputs -> first().name, output3, mapping.outputs -> first().name, 'String'); -- else -- thisModule.CreateChunk2(output6, -- mappingt1.eAttr.name, -- output3, -- mappingt1.xsdAttr.name, -- 'String'); } -- for (mappingt2 in mappingsType2) { -- mappingt2.eAttr.upperBound = -1 -- ---- if (mappingt2.eAttr.lowerBound = 1) -- required ---- thisModule.CreateChunk3(); ---- else ---- thisModule.CreateChunk4(); -- } -- for (mappingt5 in mappingsType5) { -- -- if (mappingt5.eRef.upperBound = 1) { -- simple cardinality -- -- if (mappingt5.eRef.lowerBound = 1) -- required -- thisModule.CreateChunk5(output6, -- mappingt5.eRef.name, -- output3, -- mappingt5.xsdChoiceElems -> collect(e | e.qName)); -- else -- thisModule.CreateChunk6(output6, -- mappingt5.eRef.name, -- output3, -- mappingt5.xsdChoiceElems -> collect(e | e.qName)); -- } -- -- if (mappingt5.eRef.upperBound = -1) { -- multiple cardinality -- -- if (mappingt5.eRef.lowerBound = 1) -- required -- thisModule.CreateChunk7(output6, -- mappingt5.eRef.name, -- output3, -- mappingt5.xsdChoiceElems -> collect(e | e.qName)); -- else -- thisModule.CreateChunk8(output6, -- mappingt5.eRef.name, -- output3, -- mappingt5.xsdChoiceElems -> collect(e | e.qName)); -- } -- } -- -- statements for do-block (output8) -- for (mappingt3 in mappingsType3) { -- -- if (mappingt3.eRef.upperBound = 1) { -- simple cardinality -- -- if (mappingt3.eRef.lowerBound = 1) -- required -- thisModule.CreateChunk9(output8, -- output6, -- targetMM, -- mappingt3.eRef, -- mappingt3.xsdAttr.name); -- else -- thisModule.CreateChunk10(output8, -- output3, -- output6, -- targetMM, -- mappingt3.eRef, -- mappingt3.xsdAttr.name); -- } -- if (mappingt3.eRef.upperBound = -1) { -- multiple cardinality -- ---- if (mappingt3.eRef.lowerBound = 1) -- required ---- thisModule.CreateChunk11(output8, ---- output3, ---- output6, ---- targetMM, ---- mappingt3.eRef, ---- mappingt3.xsdAttr.name); ---- else ---- thisModule.CreateChunk12(output8, ---- output3, ---- output6, ---- targetMM, ---- mappingt3.eRef, ---- mappingt3.xsdAttr.name); -- } -- } -- -- for (mappingt4 in mappingsType4) { -- mappingt4.eRef.upperBound = -1 -- ---- if (mappingt4.eAttr.lowerBound = 1) -- required ---- thisModule.CreateChunk13(output8, ---- output3, ---- output6, ---- targetMM, ---- mappingt3.eRef, ---- mappingt3.xsdRef.qName); ---- else ---- thisModule.CreateChunk14(output8, ---- output3, ---- output6, ---- targetMM, ---- mappingt3.eRef, ---- mappingt3.xsdRef.qName); -- } modul.elements <- output1; } } --- ------------------------------------------------------------------------ --- This rule is meant to be applied on a Mapping for an EAttribute [1] --- --- It creates a binding like this: --- --- eAttr_Name <- input.getXXXXXXAttrValue('Attr_Name') --- ------------------------------------------------------------------------ rule CreateChunk1(outPatternElem : ATL!OutPatternElement, eAttrName : String, inPatternElem : ATL!InPatternElement, attrName : String, primitiveType : String) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eAttrName, -- isAssignment <- -- refs. outPatternElement <- outPatternElem, value <- output2 ), -- ------------------------------------- -- input.getXXXXXXAttrValue('Attr_Name') -- ------------------------------------- output2 : ATL!OperationCallExp( -- .getXXXXXXAttrValue('Attr_Name') -- attrs. -- location <- , operationName <- 'get' + primitiveType + 'AttrValue', -- refs source <- output3, -- input. -- appliedProperty <- arguments <- output4 ), output3 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output2 ), output4 : ATL!StringExp( -- 'Attr_Name' -- attrs. -- location <- , stringSymbol <- attrName, -- refs. parentOperation <- output2 ) do { outPatternElem.bindings <- output1; } } --- ---------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType1 for an EAttribute [0..1]. --- --- It creates a binding like this: --- --- eAttr_Name <- if input.hasAttribute('Attr_Name') then --- input.getXXXXXXAttrValue('Attr_Name') --- else --- OclUndefined --- endif --- ---------------------------------------------------------------------------- rule CreateChunk2(outPatternElem : ATL!OutPatternElement, eAttrName : String, inPatternElem : ATL!InPatternElement, attrName : String, primitiveType : String) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eAttrName, -- isAssignment <- -- refs. outPatternElement <- outPatternElem, value <- output2 ), output2 : ATL!IfExp( -- attrs. -- location <- , -- refs. condition <- output3, thenExpression <- output6, elseExpression <- output9 ), -- ------------------------------- -- input.hasAttribute('Attr_Name') -- ------------------------------- output3 : ATL!OperationCallExp( -- .hasAttribute('Attr_Name') -- attrs. -- location <- , operationName <- 'hasAttribute', -- refs source <- output4, -- input. -- appliedProperty <- arguments <- output5 ), output4 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output3 ), output5 : ATL!StringExp( -- 'Attr_Name' -- attrs. -- location <- , stringSymbol <- attrName, -- refs. parentOperation <- output3 ), -- ------------------------------------- -- input.getXXXXXXAttrValue('Attr_Name') -- ------------------------------------- output6 : ATL!OperationCallExp( -- .getXXXXXXAttrValue('Attr_Name') -- attrs. -- location <- , operationName <- 'get' + primitiveType + 'AttrValue', -- refs source <- output7, -- input. -- appliedProperty <- arguments <- output8 ), output7 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output6 ), output8 : ATL!StringExp( -- 'Attr_Name' -- attrs. -- location <- , stringSymbol <- attrName, -- refs. parentOperation <- output6 ), output9 : ATL!OclUndefinedExp( -- attrs. -- location <- -- refs. ) do { outPatternElem.bindings <- output1; } } --- --------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType2 for an EAttribute [1..*] --- --- It creates a binding like this: --- --- --- --------------------------------------------------------------------------- rule CreateChunk3(outPatternElem : ATL!OutPatternElement, eAttrName : String, attrName : String) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eAttrName, -- isAssignment <- false, -- refs. outPatternElement <- outPatternElem -- value <- ) do { outPatternElem.bindings <- output1; } } --- --------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType2 for an EAttribute [0..*] --- --- It creates a binding like this: --- --- --- --------------------------------------------------------------------------- rule CreateChunk4(outPatternElem : ATL!OutPatternElement, eAttrName : String, attrName : String) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eAttrName, -- isAssignment <- false, -- refs. outPatternElement <- outPatternElem -- value <- ) do { outPatternElem.bindings <- output1; } } --- -------------------------------------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType5 for a containment EReference [1] --- --- It creates a binding statement like this: --- --- eRef_Name <- input.getChildrenElem() -> select(e | e.name = 'ComplexType1_QualifiedName' or --- e.name = 'ComplexType1_QualifiedName' or --- ... --- ... --- e.name = 'ComplexTypeN_QualifiedName') -> first() --- -------------------------------------------------------------------------------------------------------- rule CreateChunk5(outPatternElem : ATL!OutPatternElement, eRefName : String, inPatternElem : ATL!InPatternElement, qNames : Sequence(String)) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eRefName, -- isAssignment <- false, -- refs. outPatternElement <- outPatternElem, value <- output2 ), -- ----------------------- -- input.getChildrenElem() -- ----------------------- output2 : ATL!OperationCallExp( -- .getChildrenElem() -- attrs. -- location <- , operationName <- 'getChildrenElem', -- refs source <- output3 -- input. -- appliedProperty <- -- arguments <- ), output3 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output2 ) -- output4 : ATL!CollectionOperationCallExp( -- -- attrs. ---- location <- , -- -- refs. -- appliedProperty <- output5 -- ), -- output5 : ATL!IteratorExp( -- -- attrs. ---- location <- , -- name <- 'select', -- -- refs. -- appliedProperty <- output2, -- iterators <- output6 -- ), -- output6 : ATL!Iterator( -- -- attrs. ---- location <- , -- varName <- 'e' -- -- refs -- ) -- output7 : ATL!OperatorCallExp( -- -- attrs. ---- location <- , -- -- -- refs -- ) do { outPatternElem.bindings <- output1; } } --- ------------------------------------------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType5 for a containment EReference [0..1] --- --- It creates a binding statement like this: --- --- eRef_Name <- if input.hasChildrenElem() then --- input.getChildrenElem() -> select(e | e.name = 'ComplexType1_QualifiedName' or --- e.name = 'ComplexType1_QualifiedName' or --- ... --- ... --- e.name = 'ComplexTypeN_QualifiedName') -> first() --- else --- OclUndefined --- endif --- ------------------------------------------------------------------------------------------------------------- rule CreateChunk6(outPatternElem : ATL!OutPatternElement, eRefName : String, inPatternElem : ATL!InPatternElement, qNames : Sequence(String)) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eRefName, -- isAssignment <- false, -- refs. outPatternElement <- outPatternElem, value <- output2 ), output2 : ATL!IfExp( -- attrs. -- location <- , -- refs. condition <- output3, thenExpression <- output5, elseExpression <- output7 ), -- ----------------------- -- input.hasChildrenElem() -- ----------------------- output3 : ATL!OperationCallExp( -- .hasChildrenElem() -- attrs. -- location <- , operationName <- 'hasChildrenElem', -- refs source <- output4 -- input. -- appliedProperty <- -- arguments <- ), output4 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output3 ), -- ----------------------- -- input.getChildrenElem() -- ----------------------- output5 : ATL!OperationCallExp( -- .getChildrenElem() -- attrs. -- location <- , operationName <- 'getChildrenElem', -- refs source <- output6 -- input. -- appliedProperty <- -- arguments <- ), output6 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output5 ), output7 : ATL!OclUndefinedExp( -- attrs. -- location <- -- refs. ) do { outPatternElem.bindings <- output1; } } --- ----------------------------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType5 for a containment EReference [1..*]. --- --- It creates a binding statement like this: --- --- eRef_Name <- input.getChildrenElem() -> select(e | e.name = 'ComplexType1_QualifiedName' or --- e.name = 'ComplexType1_QualifiedName' or --- ... --- ... --- e.name = 'ComplexTypeN_QualifiedName') --- ----------------------------------------------------------------------------------------------- rule CreateChunk7(outPatternElem : ATL!OutPatternElement, eRefName : String, inPatternElem : ATL!InPatternElement, qNames : Sequence(String)) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eRefName, -- isAssignment <- false, -- refs. outPatternElement <- outPatternElem, value <- output2 ), -- ----------------------- -- input.getChildrenElem() -- ----------------------- output2 : ATL!OperationCallExp( -- .getChildrenElem() -- attrs. -- location <- , operationName <- 'getChildrenElem', -- refs source <- output3 -- input. -- appliedProperty <- -- arguments <- ), output3 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output2 ) do { outPatternElem.bindings <- output1; } } --- ---------------------------------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType5 for a containment EReference [0..*]. --- --- It creates a binding statement like this: --- --- eRef_Name <- if input.hasChildrenElem() then --- input.getChildrenElem() -> select(e | e.name = 'ComplexType1_QualifiedName' or --- e.name = 'ComplexType1_QualifiedName' or --- ... --- ... --- e.name = 'ComplexTypeN_QualifiedName') --- else --- OclUndefined --- endif --- ---------------------------------------------------------------------------------------------------- rule CreateChunk8(outPatternElem : ATL!OutPatternElement, eRefName : String, inPatternElem : ATL!InPatternElement, qNames : Sequence(String)) { to output1 : ATL!Binding( -- attrs. -- location <- , propertyName <- eRefName, -- isAssignment <- false, -- refs. outPatternElement <- outPatternElem, value <- output2 ), output2 : ATL!IfExp( -- attrs. -- location <- , -- refs. condition <- output3, thenExpression <- output5, elseExpression <- output7 ), -- ----------------------- -- input.hasChildrenElem() -- ----------------------- output3 : ATL!OperationCallExp( -- .hasChildrenElem() -- attrs. -- location <- , operationName <- 'hasChildrenElem', -- refs source <- output4 -- input. -- appliedProperty <- -- arguments <- ), output4 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output3 ), -- ----------------------- -- input.getChildrenElem() -- ----------------------- output5 : ATL!OperationCallExp( -- .getChildrenElem() -- attrs. -- location <- , operationName <- 'getChildrenElem', -- refs source <- output6 -- input. -- appliedProperty <- -- arguments <- ), output6 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output5 ), output7 : ATL!OclUndefinedExp( -- attrs. -- location <- -- refs. ) do { outPatternElem.bindings <- output1; } } --- ------------------------------------------------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType3 for an EReference [1] --- --- It creates a binding statement like this: --- --- output.ERef_Name <- XXXXXXXXXXXXXXXXX -> select(e | e.oclIsKindOf(MM_Name!ERef_Type)) -> --- select(e | e.name = input.getStringAttrValue('Attr_Name')) -> first(); --- ------------------------------------------------------------------------------------------------------------------- rule CreateChunk9(doBlock : ATL!ActionBlock, outPatternElem : ATL!OutPatternElement, targetMM : ATL!OclModel, eRef : Ecore!EReference, attrName : String) { to output1 : ATL!BindingStat( -- attrs. -- location <- -- isAssignment <- -- propertyName <- -- refs. source <- output2 -- value <- output4, ), output2 : ATL!NavigationOrAttributeCallExp( -- attrs. -- location <- name <- eRef.name, -- refs source <- output3 -- appliedProperty <- ), output3 : ATL!VariableExp( -- attrs. -- location <- -- refs referredVariable <- outPatternElem, appliedProperty <- output2 ) do { doBlock.statements <- output1; } } --- ------------------------------------------------------------------------------------------------------------------------ --- This rule is meant to be applied on a MappingType3 for an EReference [0..1] --- --- It creates a binding statement like this: --- --- if (input.hasAttribute('Attr_Name')) { --- output.ERef_Name <- XXXXXXXXXXXXXXXXX -> select(e | e.oclIsKindOf(MM_Name!ERef_Type)) -> --- select(e | e.name = input.getStringAttrValue('Attr_Name')) -> first(); --- } --- ------------------------------------------------------------------------------------------------------------------------ rule CreateChunk10(doBlock : ATL!ActionBlock, inPatternElem : ATL!InPatternElement, outPatternElem : ATL!OutPatternElement, targetMM : ATL!OclModel, eRef : Ecore!EReference, attrName : String) { to output1 : ATL!IfStat( -- attrs. -- location <- , -- refs. condition <- output2, thenStatements <- output5 ), -- ------------------------------ -- input.hasAttribute('Attr_Name') -- ------------------------------ output2 : ATL!OperationCallExp( -- .hasAttribute('Attr_Name') -- attrs. -- location <- , operationName <- 'hasAttribute', -- refs source <- output3, -- input. -- appliedProperty <- arguments <- output4 ), output3 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output2 ), output4 : ATL!StringExp( -- 'Attr_Name' -- attrs. -- location <- , stringSymbol <- attrName, -- refs. parentOperation <- output2 ), output5 : ATL!BindingStat( -- attrs. -- location <- -- isAssignment <- -- propertyName <- -- refs. source <- output6 -- value <- output8, ), output6 : ATL!NavigationOrAttributeCallExp( -- attrs. -- location <- name <- eRef.name, -- refs source <- output7 -- appliedProperty <- ), output7 : ATL!VariableExp( -- attrs. -- location <- -- refs referredVariable <- outPatternElem, appliedProperty <- output6 ) do { doBlock.statements <- output1; } } --- --------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType3 for an EReference [1..*] --- --- It creates a binding statement like this: --- --- for (tok in input.getStringAttrValue('Attr_Name').split(' ')) { --- output.ERef_Name <- XXXXXXXXXXXXXX -> --- select(e | e.oclIsKindOf(MM_Name!ERef_Type)) -> --- select(e | e.name = tok) -> first(); --- } --- --------------------------------------------------------------------------- rule CreateChunk11(doBlock : ATL!ActionBlock, inPatternElem : ATL!InPatternElement, outPatternElem : ATL!OutPatternElement, targetMM : ATL!OclModel, eRef : Ecore!EReference, attrName : String) { to output1 : ATL!ForStat( -- attrs. -- location <- -- refs. ) do { doBlock.statements <- output1; } } --- --------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType3 for an EReference [0..*] --- --- It creates a binding statement like this: --- --- if (input.hasAttribute('Attr_Name')) { --- for (tok in input.getStringAttrValue('Attr_Name').split(' ')) { --- output.ERef_Name <- XXXXXXXXXXXXXX -> --- select(e | e.oclIsKindOf(MM_Name!ERef_Type)) -> --- select(e | e.name = tok) -> first(); --- } --- } --- --------------------------------------------------------------------------- rule CreateChunk12(doBlock : ATL!ActionBlock, inPatternElem : ATL!InPatternElement, outPatternElem : ATL!OutPatternElement, targetMM : ATL!OclModel, eRef : Ecore!EReference, attrName : String) { to output1 : ATL!IfStat( -- attrs. -- location <- , -- refs. condition <- output2, thenStatements <- output5 ), -- ------------------------------ -- input.hasAttribute('Ref_Name') -- ------------------------------ output2 : ATL!OperationCallExp( -- .hasAttribute('Attr_Name') -- attrs. -- location <- , operationName <- 'hasAttribute', -- refs source <- output3, -- input. -- appliedProperty <- arguments <- output4 ), output3 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output2 ), output4 : ATL!StringExp( -- 'Attr_Name' -- attrs. -- location <- , stringSymbol <- attrName, -- refs. parentOperation <- output2 ), output5 : ATL!ForStat( -- attrs. -- location <- -- refs. ) do { doBlock.statements <- output1; } } --- ------------------------------------------------------------------------------ --- This rule is meant to be applied on a MappingType4 for an EReference [1..*] --- --- It creates a binding statement like this: --- --- for (elem in input.getChildrenElemByName('Ref_QualifiedName')) { --- output.ERef_Name <- XXXXXXXXXXXXXXXXXXX -> --- select(e | e.oclIsKindOf(MM_Name!ERef_Type)) -> --- select(e | e.name = elem.getStringAttrValue('Name')) -> first(); --- } --- ------------------------------------------------------------------------------ rule CreateChunk13(doBlock : ATL!ActionBlock, inPatternElem : ATL!InPatternElement, outPatternElem : ATL!OutPatternElement, targetMM : ATL!OclModel, eRef : Ecore!EReference, refQualifiedName : String) { to output1 : ATL!ForStat( -- attrs. -- location <- -- refs. ) do { doBlock.statements <- output1; } } --- ----------------------------------------------------------------------------------- --- This rule is meant to be applied on a MappingType4 for an EReference [0..1]. --- --- It creates a binding statement like this: --- --- if (input.hasChildrenElemByName('Ref_QualifiedName')) { --- for (elem in input.getChildrenElemByName('Ref_QualifiedName')) { --- output.ERef_Name <- XXXXXXXXXXXXXXXXXXX -> --- select(e | e.oclIsKindOf(MM_Name!ERef_Type)) -> --- select(e | e.name = elem.getStringAttrValue('Name')) -> first(); --- } --- } --- ----------------------------------------------------------------------------------- rule CreateChunk14(doBlock : ATL!ActionBlock, inPatternElem : ATL!InPatternElement, outPatternElem : ATL!OutPatternElement, targetMM : ATL!OclModel, eRef : Ecore!EReference, refQualifiedName : String) { to output1 : ATL!IfStat( -- attrs. -- location <- , -- refs. condition <- output2, thenStatements <- output5 ), -- ------------------------------------------------ -- input.hasChildrenElemByName('Ref_QualifiedName') -- ------------------------------------------------ output2 : ATL!OperationCallExp( -- .hasChildrenElemByName('Ref_QualifiedName') -- attrs. -- location <- , operationName <- 'hasChildrenElemByName', -- refs source <- output3, -- input. -- appliedProperty <- arguments <- output4 ), output3 : ATL!VariableExp ( -- input. -- attrs. -- location <- , -- refs. referredVariable <- inPatternElem, appliedProperty <- output2 ), output4 : ATL!StringExp( -- 'Ref_QualifiedName' -- attrs. -- location <- , stringSymbol <- refQualifiedName, -- refs. parentOperation <- output2 ), output5 : ATL!ForStat( -- attrs. -- location <- -- refs. ) do { doBlock.statements <- output1; } }